# coding:utf-8
'''
定义几个关键字，count type,protocol,country,area,
'''
import json
import config
from db.DataStore import sqlhelper


from flask import Flask
from flask import request

app = Flask(__name__)

@app.route("/del")
def delete():
    inputs = request.args

    json_result = json.dumps(sqlhelper.delete(inputs))
    return json_result


@app.route("/get")
def select():
    inputs = request.args

    json_result = json.dumps(sqlhelper.select(inputs.get('count', None), inputs))

    return json_result

@app.route("/")
def index():
    ret = """

<br>        USEAGE 
<br>        get:
<br>         http://server:8000/get
<br>        del:
<br>         http://server:8000/del
<br>

    """
    return ret


def start_api_server():
    # app.debug = True
    # app.run()
    app.run(host='0.0.0.0',port=config.API_PORT,threaded=True)
